/**
 * @author 徐楠
 * @date 2022/4/20 8:45
 * @version 1.0
 */

package com.xunan.likou;

public class LengthOfTheLastWord {
    public static void main(String[] args) {
        String s = "   fly me   to   the moon   ";
        int result = lengthOfLastWord(s);
        System.out.println(result);
    }

    public static int lengthOfLastWord(String s) {
        String[] split = s.split("\\s");
        System.out.println(split.length);
        for (String s1 : split) {
            System.out.println(s1);
        }
        int result = split[split.length - 1].length();
        return result;

    }
}
